package com.qpx.email.service;


import com.qpx.email.config.EmailProperties;
import com.qpx.email.utils.EmailManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
import java.util.List;

@Slf4j
public class EmailService {


    @Autowired
    EmailProperties emailProperties;


    /**
     * 发送邮件
     * @param subject 主题
     * @param htmlContent 内容
     * @param attachments 附件列表
     * @return
     */
    public void sendMail(String subject, String htmlContent, List<File> attachments){
        EmailManager.send(emailProperties.getToUser(),emailProperties.getCc(),subject,htmlContent,attachments);
    }


    /**
     * 发送邮件
     * @param subject 主题
     * @param htmlContent 内容
     * @return
     */
    public void sendMail(String subject, String htmlContent){
        EmailManager.send(emailProperties.getToUser(),emailProperties.getCc(),subject,htmlContent,null);
    }
}
